package com.snowleopard.findpeople.service.account.impl;

import java.util.LinkedHashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.snowleopard.findpeople.dao.account.AuthorityDao;
import com.snowleopard.findpeople.entity.account.Authority;
import com.snowleopard.findpeople.service.account.AuthorityService;

/**
 * @author LiuJian
 * @version 1.0
 * @created 20-11-2009 18:09:35
 */

@Service
@Transactional
public class AuthorityServiceImpl implements AuthorityService {

	@Autowired
	AuthorityDao authorityDao;

	public List<Authority> getUrlResourceWithAuthorities() {

		return this.authorityDao.getAuthorityWithInterceptUrl();

	}

	public LinkedHashMap<String, String> getRequestMap() throws Exception {

		List<Authority> authorityList = getUrlResourceWithAuthorities();

		LinkedHashMap<String, String> requestMap = new LinkedHashMap<String, String>(authorityList.size());

		for (Authority authority : authorityList) {
			requestMap.put(authority.getInterceptUrl(), authority.getName());
		}

		return requestMap;
	}

}